﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WmsApp.UI
{
    public partial class QStockTacking : DevExpress.XtraEditors.XtraUserControl, IQueryControl
    {
        public QStockTacking()
        {
            InitializeComponent();
        }

        public string GetCondition()
        {
            string condition = "";
            if (! String.IsNullOrEmpty(this.textEditStockTackingNo.Text.Trim()))
            {
                condition += (String.Format(" and  StockTackingNo like '%{0}%' ", this.textEditStockTackingNo.Text.Trim()));
            }

            if (!String.IsNullOrEmpty(this.textEditStockTackingCustomNo.Text.Trim()))
            {
                condition += (String.Format(" and  StockTackingCustomNo like '%{0}%' ", this.textEditStockTackingCustomNo.Text.Trim()));
            }
            
            if (!String.IsNullOrEmpty(this.textEditStockTackingYearMonth.Text.Trim()))
            {
                condition += (String.Format(" and  StockTackingYearMonth like '%{0}%' ", this.textEditStockTackingYearMonth.Text.Trim()));
            }

            if (!String.IsNullOrEmpty(this.textEditStockTackingDesc.Text.Trim()))
            {
                condition += (String.Format(" and  StockTackingDesc like '%{0}%' ", this.textEditStockTackingDesc.Text.Trim()));
            }

            DateTime dateTime;
            if (DateTime.TryParse(this.dateEditStockTackingDateFrom.Text.Trim(), out dateTime))
            {
                condition += (String.Format(" and  StockTackingTime >= '{0}' ", dateTime.ToString("yyyy-MM-dd")));
            }

            if (DateTime.TryParse(this.dateEditStockTackingDateTo.Text.Trim(), out dateTime))
            {
                condition += (String.Format(" and  StockTackingTime <= '{0}' ", dateTime.ToString("yyyy-MM-dd")));
            }
            return condition;
        }

        public void AddCustomerCondition(string condition)
        {
            throw new NotImplementedException();
        }
    }
}
